<script> 
myGB_show = function(caption, url, /* optional */ height, width, callback_fn) { 
    var options = { 
        caption: caption, 
        height: height || 500, 
        width: width || 500, 
        fullscreen: true, 
        callback_fn: callback_fn, 
        reload_on_close: true 
    } 
    var win = new GB_Window(options); 
    return win.show(url); 


} 
</script> 

<div class="task">
  <div class="enabled" onmouseover="className='hover'" onmouseout="className='enabled'" onclick="document.getElementById('form').submit();"><img src="template/default/image/save_enabled.png" alt="<?php echo $button_save; ?>" class="png" /><?php echo $button_save; ?></div>
  <div class="enabled" onmouseover="className='hover'" onmouseout="className='enabled'" onclick="location='<?php echo $cancel; ?>'"><img src="template/default/image/cancel_enabled.png" alt="<?php echo $button_cancel; ?>" class="png" /><?php echo $button_cancel; ?></div>
</div>
<?php if ($error) { ?>
<div class="warning"><?php echo $error; ?></div>
<?php } ?>
<div class="heading"><?php echo $heading_title; ?></div>
<div class="description"><?php echo $heading_description; ?></div>
<script type="text/javascript" src="javascript/tab/tab.js"></script>
<link rel="stylesheet" type="text/css" href="javascript/tab/tab.css" />
<script type="text/javascript" src="javascript/fckeditor/fckeditor.js"></script>

<script type="text/javascript" src="javascript/greybox/AJS.js"></script>
<script type="text/javascript" src="javascript/greybox/AJS_fx.js"></script>
<script type="text/javascript" src="javascript/greybox/gb_scripts.js"></script>

<script type="text/javascript" src="javascript/ajax/jquery.js"></script>

<link href="javascript/greybox/gb_styles.css" rel="stylesheet" type="text/css" />

<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form" name="form">
  <div class="tab" id="tab">
    <div class="tabs"><a><?php echo $tab_general; ?><a>Grupos</a></div>
    <div class="pages">
      <div class="page">
        <div class="pad">
          <table>
            <tr>
	          <td width="185"><span class="required">*</span> <?php echo $entry_persona; ?></td>
              <td>
              
              <?php
              	 if ($_REQUEST['action'] == 'update') { ?> 
              	<input type="text" name="persona" value="<?php echo $persona; ?>" readonly/>
               <?php } 
               	else
               	{
               ?>
              	<input type="text" name="persona" value="<?php echo $persona; ?>"/>
              <?php } ?> 
                <?php if ($error_persona) { ?>
                <span class="error"><?php echo $error_persona; ?></span>
                <?php } ?></td>
           </tr>            
            <tr>
	          <td width="185"><span class="required">*</span> <?php echo $entry_nombre; ?></td>
              <td><input type="text" name="nombre" value="<?php echo $nombre; ?>" size="50" />
                <?php if ($error_nombre) { ?>
                <span class="error"><?php echo $error_nombre; ?></span>
                <?php } ?></td>
           </tr>
            <tr>
	          <td width="185"><span class="required">*</span> <?php echo $entry_mail; ?></td>
              <td><input type="text" name="mail" value="<?php echo $mail; ?>" size="50"/>
                <?php if ($error_mail) { ?>
                <span class="error"><?php echo $error_mail; ?></span>
                <?php } ?>              
              </td>
           </tr>
           <tr>
                <td width="185"><span class="required">*</span> <?php echo $entry_provincia; ?></td>
                <td>
                    <select name="provincia" id = "provincia" onclick="getLocalidades();">
                        <option value="0" selected>Seleccione......</option>
                         <?php
                           foreach ($provincias as $prov)
                           {
                                if ($prov['codigo'] == $provincia)
                                {
                                ?>
                                    <option value=<?php echo $prov['codigo']; ?> selected><?php echo $prov['descripcion']; ?></option>
                                <?php
                                  } else {
                                 ?>
                                     <option value=<?php echo $prov['codigo']; ?>><?php echo $prov['descripcion']; ?></option>
                               <?php
                                    }
                            } ?>
                    </select>
                </td>
                <td width="185"><span class="required">*</span> <?php echo $entry_localidad; ?></td>
                <td>
                    <select name="localidad" id="localidad">
                        <option value="0" selected>Seleccione......</option>
                         <?php
                           foreach ($localidades as $loc)
                           {
                                if ($loc['localidad'] == $localidad)
                                {
                                ?>
                                    <option value=<?php echo $loc['localidad']; ?> selected><?php echo $loc['descripcion']; ?></option>
                                <?php
                                  } else {
                                 ?>
                                     <option value=<?php echo $loc['localidad']; ?>><?php echo $loc['descripcion']; ?></option>
                               <?php
                                    }
                            } ?>
                    </select>
                <?php if ($error_localidad) { ?>
                <span class="error"><?php echo $error_localidad; ?></span>
                <?php } ?>
                </td>
            </tr>
	</table>
        </div>
      </div>

      <div class="page">
        <div class="pad">
          <table>
            <tr>
				<td width="400">
				<?php foreach ($grupos as $grupo) { 
				 ?>				
				<?php if (!$grupo['persona']) { ?>
				<input type="checkbox" name="grupos[]" value="<?php echo $grupo['grupo']; ?>"><?php echo $grupo['descripcion']; ?><br>	
				<?php } else { ?>
				<input type="checkbox" name="grupos[]" value="<?php echo $grupo['grupo']; ?>" checked><?php echo $grupo['descripcion']; ?><br>	
				<?php } ?>
				<?php } ?>
				</td>            
            </tr>
		</table>
        </div>
      </div>
    </div>            
  </div>
 
  <script type="text/javascript"><!--
  tabview_initialize('tab');
  //--></script>

<script type="text/javascript"><!--

	function getLocalidades()
	{
		var idProvincia = $("#provincia").val();
               
                //alert (idProvincia);

		$.ajax(
		{
			dataType: "html",
			type: "GET",
			url: "index.php?controller=persona&action=obtenerLocalidades",  //controladora personas y funcion obtenerlocalidades
                        data: "provincia_id=" + idProvincia,
            beforeSend: function(data)
				 {
					$("#localidad").html('<option>Cargando...</option>');   //carga un texto mienstras carga ej: cargando
					//También puedes poner aqui el gif que indica cargando...
                 },
            success: function(requestData)
				 {  	//Llamada exitosa
				 	 //alert(requestData);
                                        $("#localidad").html(requestData);  //Usando JQUERY, Cargamos los talles en combo localidades
                 },
            error: function(requestData, strError, strTipoError)
		{
					alert("Error " + strTipoError +': ' + strError); //En caso de error mostraremos un alert
                }
         });
	}

   //--></script>

</form>